<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @property bool $is_good 推荐:0=否,1=是
 * @property bool $type 类型:1=优才计划,2=高才计划,3=专才计划,4=留学
 * @property float $latitude 纬度
 * @property float $longitude 经度
 * @property int $browse 浏览量
 * @property int $collect 收藏数
 * @property int $comment 评论数量
 * @property int $deletetime
 * @property int $id
 * @property int $like 点赞数
 * @property int $users_id 用户
 * @property string $adcode
 * @property string $address 地址
 * @property string $content 内容
 * @property string $createtime
 * @property string $images 图片
 * @property string $title 标题
 * @property string $video_files 视频
 * @property-read \app\model\Users $users
 * @property-read \app\model\UsersCollect $users_collect
 * @property-read \app\model\UsersLike $users_like
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 * @mixin \think\Model
 */
class Talent extends Model
{
    use SoftDelete;
    protected $deleteTime = 'deletetime';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
//    public static function onBeforeInsert(Model $model): mixed
//    {
//        if (empty($model->getAttr('images'))){
//            if ($model->getAttr('type')==1){
//                $images = Config::where(['name'=>'talent1'])->value('value');
//            }
//            if ($model->getAttr('type')==2){
//                $images = Config::where(['name'=>'talent2'])->value('value');
//            }
//            if ($model->getAttr('type')==3){
//                $images = Config::where(['name'=>'talent3'])->value('value');
//            }
//            if ($model->getAttr('type')==4){
//                $images = Config::where(['name'=>'talent4'])->value('value');
//            }
//            $model->setAttr('images',$images);
//        }
//        return  true;
//    }
    public function users()
    {
        return $this->belongsTo(Users::class, 'users_id');
    }

    public function usersCollect()
    {
        return $this->hasOne(UsersCollect::class,'pro_id');

    }

    public function usersLike()
    {
        return $this->hasOne(UsersLike::class,'pro_id');
    }

}
